<style type="text/css">
    .demo-upload-list {
        display: inline-block;
        width: 60px;
        height: 60px;
        text-align: center;
        line-height: 60px;
        border: 1px solid transparent;
        border-radius: 4px;
        overflow: hidden;
        background: #fff;
        position: relative;
        box-shadow: 0 1px 1px rgba(0, 0, 0, .2);
        margin-right: 4px;
    }

    .demo-upload-list img {
        width: 100%;
        height: 100%;
    }

    .demo-upload-list-cover {
        display: none;
        position: absolute;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(0, 0, 0, .6);
    }

    .demo-upload-list:hover .demo-upload-list-cover {
        display: block;
    }

    .demo-upload-list-cover i {
        color: #fff;
        font-size: 20px;
        cursor: pointer;
        margin: 0 2px;
    }

    .selected-search {
        box-shadow: 0 1px 6px rgba(0, 0, 0, .2);
        height: 200px;
        width: 260px;
        position: relative;
        border-radius: 4px;
    }

    .selected-search .search-action {
        position: absolute;
        top: 10px;
        left: 10px;
        right: 10px;
    }

    .selected-search .selected-arr {
        position: absolute;
        top: 50px;
        left: 20px;
        right: 20px;
        bottom: 10px;
        overflow: scroll;
    }

    .select-click {
        border: 1px solid #dddee1;
        border-radius: 4px;
        padding: 0 10px;
        margin-bottom: 10px;
    }

    .selected-search .selected-arr .selected-item {
        /*border-bottom: 1px solid #dfdfdf;*/
    }
</style>
<template>
    <i-form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="100">
        <Form-item label="接口地址" prop="interfaceurl">
            <i-input v-model="formValidate.interfaceurl" placeholder="请输入接口地址"></i-input>
        </Form-item>
        <Form-item label="功能项描述" prop="description">
            <i-input v-model="formValidate.description" placeholder="请输入功能项描述"></i-input>
        </Form-item>
        <!--<Form-item label="选择分组" prop="description">-->
            <!--<Tree @on-check-change="checkOnchangeEvent" :data="baseData" show-checkbox></Tree>-->
        <!--</Form-item>-->
        <Form-item>
            <i-button @click="handleSubmit('formValidate')" type="primary">提交</i-button>
            <i-button type="ghost" @click="jumpPage()" style="margin-left: 8px">返回</i-button>
        </Form-item>
    </i-form>
</template>
<script>
    import apiUtil from '../../assets/utils/api_util';
    import baseUtil from '../../assets/utils/base-util';

    export default {
        data() {
            return {
                formValidate: {
                    //添加字段
                    interfaceurl: '',
                    description: '',
                },
                ruleValidate: {},
                prevID: '',
            }
        },
        mounted: function () {
            // this.getPeopelData();
            if (this.$route.query.id) {
                this.prevID = this.$route.query.id;
            }
            // this.uploadList();
        },

        methods: {
            //跳转
            jumpPage: function (id, url) {
                this.$router.back(-1)

            },
            checkOnchangeEvent:function(data){
                console.log('树的数据:',data)
            },
            changeOutDate: function (date) {
                console.log(date);
                this.formValidate.outdate = date;
            },
            handleSubmit(name) {
                let that = this;
                let model = this.$refs[name].model;
                this.$refs[name].validate((valid) => {
                    that.addData(model);
                })
            },
            //获取负责人
            getPeopelData() {
                let that = this;

                let para = {
                    curPage: 1,
                    pageSize: '',
                };

                this.$Loading.start();

                apiUtil.get(that, apiUtil.urls.userList, para, function (res) {
                    that.$Loading.finish();
                    that.selectPeopelIsShow = true;
                    that.principalArr = res.Msg.Arrays;
                });
            },
            choosePeople: function (id, name) {
                this.principalId = id;
                this.personalName = name;
                this.selectPeopelIsShow = false;
            },
            //添加
            addData: function (model) {
                let that = this;

                model.groupid =this.$route.query.id;

                let params = that.$qs.stringify(model);
                this.$Loading.start();

                console.log('params:', params);
                apiUtil.post(that, apiUtil.urls.AddStructure, params, function (res) {
                    that.$Loading.finish();

                    that.$Modal.confirm({
                        title: '操作成功',
                        content: '请选择下一步操作',
                        okText: '继续添加',
                        cancelText: '返回列表',
                        onOk: () => {
                        },
                        onCancel: () => {
                            baseUtil.pageJump(that, '', 'GroupGroupList')
                        }
                    });

                });
            },

        }
    }
</script>
